
//LCR 068. 搜索插入位置
public class Demo2 {
    class Solution {
        public int searchInsert(int[] nums, int target) {
            if(target<nums[0]){
                return 0;
            }
            int left=0;
            int right=nums.length-1;
            while(left<right){
                int mid=left+(right-left+1)/2;
                if(nums[mid]<=target){
                    left=mid;
                }else{
                    right=mid-1;
                }
            }
            if(nums[left]==target){
                return left;
            }
            return left+1;
        }

    }

}
